<template>
  <div>
    <div class="btn_add" @click="showStepper" v-show="!stepperVisible">
      <van-icon name="plus" />
    </div>

    <van-stepper
      v-model="num"
      v-show="stepperVisible"
      min="0"
      disable-input
      @minus="subStepper"
    />
  </div>
</template>
<script>
export default {
  data() {
    return {
      num: 0,
      stepperVisible: false
    };
  },
  methods: {
    // 点击+号显示计数器
    showStepper() {
      this.stepperVisible = !this.stepperVisible;
      this.num++
    },
    //点击计数器的减号的时候
    subStepper() {
        if(this.num === 1) {
            this.stepperVisible = !this.stepperVisible;
            this.num--
            console.log('this.num: ', this.num);
        }
    }
  }
};
</script>
<style lang="less" scoped></style>
